<template>
  <j-modal
    :title="detailtype == 5 ? '订单详情' : '咨询详情'"
    :width="1000"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    :footer="false"
    cancelText="关闭"
  >
    <a-spin :spinning="confirmLoading">
      <!-- <a-form-model ref="form" :model="model" :rules="validatorRules">
      
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orderNumber" label="订单编号">
          <a-input placeholder="请输入订单编号" v-model="model.orderNumber" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orderTime" label="订单时间">
          <a-date-picker showTime valueFormat='YYYY-MM-DD HH:mm:ss' v-model="model.orderTime" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orderStatus" label="订单状态（0.待支付、1.已支付、2.已关闭）">
          <a-input placeholder="请输入订单状态（0.待支付、1.已支付、2.已关闭）" v-model="model.orderStatus" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="needHeSaidPrice" label="需支付他币">
          <a-input-number v-model="model.needHeSaidPrice"/>
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="heSaidPrice" label="实际支付他币">
          <a-input-number v-model="model.heSaidPrice"/>
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="consultantId" label="专家名称">
          <a-input placeholder="请输入专家名称" v-model="model.consultantId" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="consultationTime" label="咨询时间">
          <a-date-picker showTime valueFormat='YYYY-MM-DD HH:mm:ss' v-model="model.consultationTime" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="consultationDuration" label="咨询时长（分钟）">
          <a-input-number v-model="model.consultationDuration"/>
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="consultationUnitPrice" label="咨询单价">
          <a-input-number v-model="model.consultationUnitPrice"/>
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="consultationQuestions" label="咨询问题">
          <a-input placeholder="请输入咨询问题" v-model="model.consultationQuestions" />
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="userId" label="咨询人">
          <a-input-number v-model="model.userId"/>
        </a-form-model-item>
        <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="consultantType" label="咨询方式（0：视频；1：线下）">
          <a-input placeholder="请输入咨询方式（0：视频；1：线下）" v-model="model.consultantType" />
        </a-form-model-item>
		
      </a-form-model> -->

      <a-descriptions bordered v-if="detailtype == 5" >
        <a-descriptions-item label="订单编号">
          {{model.orderNumber}}
        </a-descriptions-item>
        <a-descriptions-item label="订单时间">
         {{model.orderTime}}
        </a-descriptions-item>
        <a-descriptions-item label="订单状态">
          {{model.orderStatus == 0 ? '待支付' : model.orderStatus== 1 ? '已支付' : '已关闭'}}
        </a-descriptions-item>
        <a-descriptions-item label="需支付他币">
          {{model.needHeSaidPrice}}
        </a-descriptions-item>
        <a-descriptions-item label="实际支付他币">
         {{model.heSaidPrice}}
        </a-descriptions-item>
      </a-descriptions>
      <a-descriptions bordered v-else >
        <a-descriptions-item label="专家名称">
          {{model.expertName}}
        </a-descriptions-item>
        <a-descriptions-item label="咨询时间">
         {{model.consultationTime}}
        </a-descriptions-item>
        <a-descriptions-item label="咨询时长（分钟）">
          {{model.consultationDuration}}
        </a-descriptions-item>
        <a-descriptions-item label="咨询单价">
          {{model.consultationUnitPrice}}
        </a-descriptions-item>
        <a-descriptions-item label="咨询问题">
         {{model.consultationQuestions}}
        </a-descriptions-item>
        <a-descriptions-item label="咨询方式">
         {{model.consultantType == 0 ? '视频' : '线下'}}
        </a-descriptions-item>
      </a-descriptions>
    </a-spin>
  </j-modal>
</template>

<script>
import { httpAction } from "@/api/manage";
import moment from "moment";

export default {
  name: "PaymentOrderInfoModal",
  data() {
    return {
      title: "操作",
      visible: false,
      model: {},
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },

      confirmLoading: false,
      validatorRules: {},
      url: {
        add: "/paymentOrderInfo/paymentOrderInfo/add",
        edit: "/paymentOrderInfo/paymentOrderInfo/edit",
      },
      detailtype: "",
    };
  },
  created() {},
  methods: {
    add() {
      //初始化默认值
      this.edit({});
    },
    edit(record, type) {
      this.detailtype = type;
      console.log(type, "type");
      this.model = Object.assign({}, record);
      this.visible = true;
    },
    close() {
      this.$emit("close");
      this.visible = false;
      this.$refs.form.clearValidate();
    },
    handleOk() {
      const that = this;
      // 触发表单验证
      this.$refs.form.validate((valid) => {
        if (valid) {
          that.confirmLoading = true;
          let httpurl = "";
          let method = "";
          if (!this.model.id) {
            httpurl += this.url.add;
            method = "post";
          } else {
            httpurl += this.url.edit;
            method = "put";
          }
          httpAction(httpurl, this.model, method)
            .then((res) => {
              if (res.success) {
                that.$message.success(res.message);
                that.$emit("ok");
              } else {
                that.$message.warning(res.message);
              }
            })
            .finally(() => {
              that.confirmLoading = false;
              that.close();
            });
        } else {
          return false;
        }
      });
    },
    handleCancel() {
      this.close();
    },
  },
};
</script>

<style lang="less" scoped></style>
